﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package com.yy.manager {

    public class LanguageManager {

        public static const XML_TYPE:String = "xml";
        public static const JSON_TYPE:String = "json";

        private var textDic:Object;

        public function LanguageManager(){
            this.textDic = {};
            super();
        }
        public function initialize(_arg1, _arg2:String="xml"):void{
            var _local3:XML;
            var _local4:XMLList;
            var _local5:XML;
            var _local6:String;
            var _local7:String;
            if (_arg1){
                if (_arg2 == LanguageManager.XML_TYPE){
                    if ((_arg1 is XML)){
                        _local3 = (_arg1 as XML);
                    } else {
                        _local3 = new XML(_arg1.toString());
                    };
                    _local4 = _local3..r;
                    for each (_local5 in _local4) {
                        _local6 = _local5.@name;
                        _local7 = _local5[0];
                        this.textDic[_local6] = _local7;
                    };
                };
            };
        }
        public function getString(_arg1:String, _arg2:String, _arg3:Array=null):String{
            return (this.getText(_arg2, _arg3));
        }
        public function getText(_arg1:String, _arg2:Array=null):String{
            var _local3:String;
            var _local4:int;
            var _local5:int;
            var _local6:String;
            var _local7:RegExp;
            if (this.textDic[_arg1] != null){
                _local3 = this.textDic[_arg1];
            } else {
                _local3 = _arg1;
            };
            if (_arg2){
                _local4 = 0;
                _local5 = _arg2.length;
                while (_local4 < _local5) {
                    _local6 = (("\\{" + _local4) + "\\}");
                    _local7 = new RegExp(_local6, "g");
                    _local3 = _local3.replace(_local7, _arg2[_local4]);
                    _local4++;
                };
            };
            return (_local3);
        }

    }
}//package com.fminutes.vinciUI.manager 
